package com.bdqn.boot.controller;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Hasee
 * @version 1.0
 * @className ParamsController
 * @description TODD
 * @date 2025/2/21 14:58
 */
@RestController
public class ParamsController {
    @RequestMapping("/goto")
    public String gotos(HttpServletRequest request) {
        request.setAttribute("msg", "成功了");
        request.setAttribute("code",200);
        //转发
        return "forward:success";
    }

    @ResponseBody
    @RequestMapping("/successa")
    public Map success(@RequestAttribute("msg") String msg,
                          @RequestAttribute("code") Integer code) {
        Map<String, Object> map = new HashMap<>();
        map.put("msg", msg);
        map.put("code", code);
        return map;
    }

    @ResponseBody
    @RequestMapping("/car/{path}")
    public Map<String, Object> testCar(@MatrixVariable("low") Integer low,
                                       @MatrixVariable("brand") List<String> list) {
        Map<String, Object> map = new HashMap<>();
        map.put("low", low);
        map.put("brand", list);
        return map;
    }
}
